package com.leetcode.p400;

import java.util.Arrays;

public class Test455 {

    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);

        int result = 0;

        for (int i = 0, j = 0; i < g.length && j < s.length; ) {
            if (s[j] >= g[i]) {
                i++;
                j++;
                result++;
            } else {
                j++;
            }
        }

        return result;
    }

    public static void main(String[] args) {
        Test455 test = new Test455();

//        int[] nums1 = new int[]{1, 2, 3};
//        int[] nums2 = new int[]{1, 1};

        int[] nums1 = new int[]{7, 8, 9, 10};
        int[] nums2 = new int[]{5, 6, 7, 8};

        int result = test.findContentChildren(nums1, nums2);

        System.out.println(result);
    }
}
